package com.yanfan.zutai.service.impl;


import cn.hutool.core.lang.Snowflake;
import cn.hutool.core.util.IdUtil;
import com.yanfan.zutai.domain.BDeviceComConfig;
import com.yanfan.zutai.mapper.BDeviceComConfigMapper;
import com.yanfan.zutai.service.IBDeviceComConfigService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 通讯口配置Service业务层处理
 *
 * @author ruoyi
 * @date 2023-06-10
 */
@Service
public class BDeviceComConfigServiceImpl implements IBDeviceComConfigService {
    @Autowired
    private BDeviceComConfigMapper bDeviceComConfigMapper;

    /**
     * 查询通讯口配置
     *
     * @param id 通讯口配置主键
     * @return 通讯口配置
     */
    @Override
    public BDeviceComConfig selectBDeviceComConfigById(Long id) {
        return bDeviceComConfigMapper.selectBDeviceComConfigById(id);
    }

    /**
     * 查询通讯口配置列表
     *
     * @param bDeviceComConfig 通讯口配置
     * @return 通讯口配置
     */
    @Override
    public List<BDeviceComConfig> selectBDeviceComConfigList(BDeviceComConfig bDeviceComConfig) {
        return bDeviceComConfigMapper.selectBDeviceComConfigList(bDeviceComConfig);
    }

    /**
     * 新增通讯口配置
     *
     * @param bDeviceComConfig 通讯口配置
     * @return 结果
     */
    @Override
    public int insertBDeviceComConfig(BDeviceComConfig bDeviceComConfig) {
        Snowflake snowflake = IdUtil.getSnowflake(6, 2);
        long id = snowflake.nextId();
        bDeviceComConfig.setId(id);
        return bDeviceComConfigMapper.insertBDeviceComConfig(bDeviceComConfig);
    }

    /**
     * 修改通讯口配置
     *
     * @param bDeviceComConfig 通讯口配置
     * @return 结果
     */
    @Override
    public int updateBDeviceComConfig(BDeviceComConfig bDeviceComConfig) {
        return bDeviceComConfigMapper.updateBDeviceComConfig(bDeviceComConfig);
    }

    /**
     * 批量删除通讯口配置
     *
     * @param ids 需要删除的通讯口配置主键
     * @return 结果
     */
    @Override
    public int deleteBDeviceComConfigByIds(Long[] ids) {
        return bDeviceComConfigMapper.deleteBDeviceComConfigByIds(ids);
    }

    /**
     * 删除通讯口配置信息
     *
     * @param id 通讯口配置主键
     * @return 结果
     */
    @Override
    public int deleteBDeviceComConfigById(Long id) {
        return bDeviceComConfigMapper.deleteBDeviceComConfigById(id);
    }
}
